home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11662 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  769 b 

  1. Path: newshost.uwo.ca!usenet
  2. From: turnbull@canlon.physics.uwo.ca (David Turnbull)
  3. Newsgroups: comp.lang.c++
  4. Subject: "free"ing classes when the "new" is inside a function
  5. Date: Fri, 15 Mar 1996 16:53:21 GMT
  6. Organization: University of Western Ontario
  7. Message-ID: <4ic7a5$94u@falcon.ccs.uwo.ca>
  8. NNTP-Posting-Host: ditto.physics.uwo.ca
  9. X-Newsreader: Forte Free Agent 1.0.82
  10.  
  11. I have code something like
  12.  
  13. MyClass* Myfunc(){
  14.   Class* value;
  15. .
  16. .
  17.   value = new MyClass(........);    <- 1 of several possible constructors
  18. .
  19.   return value;
  20. }
  21.  
  22.  
  23. ------ in main---------
  24. .
  25. Class* value;
  26. value=Myfunc();
  27. .
  28.  
  29. How do I free up the memory allocated to value?
  30. delete value won't do it.
  31.  
  32. Thanks.
  33.  
  34. David Turnbull
  35. Department of Physics
  36. University of Western Ontario
  37. London, Ontario, Canada
  38.  
  39.